Skip to content

Conversation

@henryiii
Copy link
Contributor

Close #1067 and close #441.

This:

  • Adds normalization to _validate_pre, which causes __replace__ to support un-normalized strings for pre. So now pre=("alpha", 1) is supported, and gets normalized to ("a", 1). This should reduce the desire to use _parse_letter_version.
  • Adds a new public function, normalize_pre, which does the normalization. We don't have to have this, but without it https://github.com/pypa/hatch/blob/hatchling-v1.28.0/backend/src/hatchling/version/scheme/standard.py#L40-L44 would require a little more work.
  • Adds a new classmethod, Version.from_parts, which constructs a version from parts. It's quite similar to __replace__, but implemented separately for performance and because it's a little simpler when it comes to None values.

@henryiii henryiii marked this pull request as draft January 30, 2026 17:25
@henryiii
Copy link
Contributor Author

henryiii commented Jan 30, 2026

Haven't added tests yet, forgot to open as draft. Also want to check performance impact, which I think is small. Thoughts on this approach?

@notatallshaw notatallshaw self-requested a review January 30, 2026 17:37
@notatallshaw
Copy link
Member

Probably good but I want to think about this, I won't have time for at least the next few days though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide Public API to normalize version parts provide mechanism to construct a version from the normalized metadata

2 participants